#ifndef FILEPROCESSOR
#define FILEPROCESSOR

#include <fstream>
#include <iostream>
#include <string>
#include "../StringProcessor/StringProcessor.h"
using namespace std;
class FileProcessor{
	public:
		static vector<string> readFileContentByLine(string);
		static string readFileToString(string);
	private:			
 };

 string FileProcessor::readFileToString(string stfile){


	string rt;
	/*
  pFile = fopen ( stfile.c_str() , "rb" );
  if (pFile==NULL) {fputs ("File error",stderr); exit (1);}

  // obtain file size:
  fseek (pFile , 0 , SEEK_END);
  lSize = ftell (pFile);
  rewind (pFile);

  // allocate memory to contain the whole file:
  buffer = (char*) malloc (sizeof(char)*lSize);
  if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}

  // copy the file into the buffer:
  result = fread (buffer,1,lSize,pFile);
  if (result != lSize) {fputs ("Reading error",stderr); exit (3);}



  // terminate
  fclose (pFile);
	rt=buffer;
  free (buffer);
	*/

	ifstream in(stfile.c_str());
	string storage; // We will read the contents here.
	in.unsetf(ios::skipws); // No white space skipping!
	std::string str((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
	return str;
 }
 vector<string> FileProcessor::readFileContentByLine(string stfile){
	vector<string> line;
	string strFromFile=readFileToString(stfile);
	line=StringProcessor::explode("\n",strFromFile);
	if(line.size()==0)line=StringProcessor::explode("\r\n",strFromFile);
	return line;
 }


#endif
